#include "comm.hpp"

int main()
{
    //打开命名管道
    int fd = open(fileName.c_str(), O_RDONLY);
    if(fd < 0)
    {
      std::cout << errno << " : " << strerror(errno) << std::endl;
      exit(-1);
    }
    //读取内容
    while(1)
    {
      char buffer[NUM];
      int n = read(fd, buffer, sizeof(buffer));
      if(n > 0)
      {
        buffer[n] = '\0';
        std::cout << "i am process B, i get message : " << buffer << std::endl;
      }
      else if(n == 0)
      {
        std::cout << "communication finish" << std::endl;
        break;
      }
      else
      {
        std::cout << errno << " : " << strerror(errno) << std::endl;
        break;
      }
      sleep(1);
    }
    close(fd);
    //unlink(fileName.c_str());
    return 0;
}
